package com.auxgroup.hr.front.commons.config;

import javax.annotation.PostConstruct;

import com.auxgroup.hr.front.commons.security.StringToDateConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;

/**
 * 处理字符串转日期问题
 * @author penghui
 * @Date 2017年10月25日
 */
@Configuration
public class WebVoChangeConfig {
	
	@Autowired
	private RequestMappingHandlerAdapter handlerAdapter;
	
	
	@PostConstruct
	public void initEditableValidation(){
		ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer)handlerAdapter.getWebBindingInitializer();
		if(initializer.getConversionService()!=null){
			GenericConversionService service = (GenericConversionService)initializer.getConversionService();
			service.addConverter(new StringToDateConverter());
		}
	}
}
